home *** CD-ROM | disk | FTP | other *** search
/ Winzipper / Winzipper_ISO.iso / internet / net commander 1.0 / ISP / SCRPTLST / SONIC.CMD < prev    next >
Encoding:
Text File  |  1996-02-27  |  10.8 KB  |  343 lines

  1.  
  2.  
  3. ##########################################################################
  4. #
  5. #                              LOGIN.CMD   v0.8 (Gen-A-Sys) 
  6. #
  7. #  A trumpet winsock login script for users of Sonic (West Sonoma County).
  8. #  ----------------------------------------------------------------------
  9. #Abstract:
  10. #
  11. #    The default LOGIN.CMD shipped with trumpet winsock is NOT a "catch all" 
  12. #script designed to work on everything, nor does it catch configuration
  13. #problems or provide any serious diagnostic feedback to the user. 
  14. #
  15. #    This script is designed to replace the default login.cmd file,
  16. #provides for extreamly robust error handling, and will work "out of the box"
  17. #in more configurations that the default login script ever could. It
  18. #makes provisions for quite a few odd situations that would normally 
  19. #prevent a less-able script from connecting.
  20. #
  21. #
  22. # *** This version is for testing purpose only, release to persons outside
  23. # of the testing group, while not prohibited, is NOT reccomended! ***
  24. #
  25. #    
  26. # "Can you say, Overkill?...."
  27. #
  28. #Mike Ireton [qix@sonic.net]
  29. #
  30. #  if ! %ppp" statement - since sonic only supports PPP, this is how we'll
  31. # catch users who try to login ppp but have trumpet configured for slip.
  32. #
  33. #
  34. if ! %ppp
  35.    Display \n\nERROR:\nSonic only supports PPP, please re-configure\N
  36.    Display Trumpet to use INTERNAL PPP (under the FILE, Setup menu)\n
  37.    Display and then try again.\n
  38.    abort
  39. end
  40.  
  41.  
  42. #
  43. # Get Phone number, username and password.
  44. #
  45. if ![load $number]
  46.   if [query $number "Enter your dial up phone number"]
  47.     save $number
  48.   end
  49. end
  50. if ![load $username]
  51.   if [username "Enter your login username"]
  52. #
  53. # It would be nice to try and catch illegal usernames here, but then
  54. # we'd have to make the same edits to setup.cmd and then it'd be a 
  55. # maintinence nightmare. We'll catch these later on in the script.
  56. #
  57. #
  58.     save $username
  59.   end
  60. end
  61. if ![load $password]
  62.   if [password "Enter your login password"]
  63.     save $password
  64.   end
  65. end
  66. #
  67. # Fix #1: Initializing the modem.
  68. # -------------------------------
  69. #
  70. #      By default, we should assume that the user's modem will simply 
  71. #      work properly if we give it an ATZ command. Trumpet's default
  72. #      script wants to send "&c1&k3", which may not be recognised by
  73. #      all modems, and which may be interpreted differently by diferent
  74. #      modems. 
  75. #
  76. #      Any user who has a modem that cannot connect to sonic given thier
  77. #      modems' default configuration (via ATZ), more than likely has a 
  78. #      configuration problem that will need to be addressed first.
  79. #
  80. #                        USER CONFIGURATION VARIABLES 
  81. #
  82. $modemsetup = "ATZ"
  83. %attempts = 0 
  84. %inittime = 5
  85. %debuglevel = 1
  86. #----------------------------
  87. #
  88. # Script constants that should never be altered
  89. # ---------------------------------------------
  90. #
  91. # You should not ever have to change the command prefix string, unless you
  92. # are using a modem that is not hayes compatible, in which case you will
  93. # will have to change lots of other things, in which case you would probbly
  94. # be better off writing a login script from scratch!
  95. #
  96. $cmdprefix = "AT" 
  97. $dialprefix = "ATDT"
  98. #
  99. # You should not ever have to change the "connect" string - that is, a 
  100. # recognisable sequence of characters your modem will send out whenever
  101. # you make a connection to another modem. Some modems will send out things
  102. # like "CARRIER xxxx" and "PROTOCOL xxxx" and _then_ "CONNECT xxxx" - 
  103. # the message should always be keyed to the very last line your modem will
  104. # return when a connect is made.
  105. #
  106.  
  107. $connect = "CONNECT"
  108. $okprefix = "OK"
  109. $errorprefix = "ERROR"
  110. #
  111. # You should never *ever* have to modify these, unless Sonic has a
  112. # _serious_ change of hardware (gets ported to the playstation? hahaha)
  113. #
  114. $userprompt = "login:"
  115. $passprompt = "assword:"
  116. #
  117. #
  118. #----------------------------------------------------------
  119. #
  120. # Fix #2: Actually doing the modem initialization.
  121. # ------------------------------------------------
  122. #
  123. #     Here is our first opportunity to catch misconfigured hardware or
  124. #software. We will send out the "modemsetup" string, and see wether or
  125. #not we get an ok response. 
  126. #
  127. # If we get an ERROR response, we should inform the user of this - It means
  128. # that some portion of the init string was NOT understood, and that the login
  129. # process will not continue (until they correct the error).
  130. #
  131. # If we don't get any response at all, that means one of:
  132. #    
  133. # 1) The user is already online and connected.
  134. # 2) The user has selected the wrong com port and bps setting 
  135. # 3) Their hardware is broken. 
  136. # 4) Their hardware is not hayes compatible (We can't support it)
  137. #
  138. # We can't rely on DCD to determine status, as a number of other software
  139. # packages on the market (PcAnywhere, for example) incorrectly sets DCD 
  140. # "On at all times" for no good reason other than to do it. Since we might
  141. # be subject to a "residue" issue with another modem package, we avoid
  142. # the issue entirely and act as if this signal was not available (and take
  143. # the long way around).
  144. output \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\n
  145. sleep 2
  146.  
  147. output $modemsetup\n
  148.  
  149. #--------------------------------
  150. # The start of a big loop - 
  151. #
  152. # We begin by getting input from the modem to determine wether or not
  153. # we recognise the response. We'll loop up to 3 times around to get
  154. # something we recognise and if we don't see it we'll give up and
  155. # die. 
  156. %i = 0
  157. repeat
  158.  
  159. if ! [read 15 $result]
  160.  
  161.     display DEBUG: Your modem is NOT responding to commands!\n
  162.     display DEBUG: -----------------------------------------\n
  163.     display DEBUG: This can be caused by any of the following:\n\n
  164.     display DEBUG: 1) You already are online and connected.\n
  165.     display DEBUG: 2) You have specfied an incorrect comport or baud rate for your modem.\n
  166.     display DEBUG: 3) Your modem is defective. \n
  167.     display DEBUG: Correct this situation and try again.\n
  168.     display DEBUG: Script Aborting.\n
  169.     abort
  170.  
  171. end
  172.  
  173. %yok = pos($okprefix,$result) > 0
  174. %yerror = pos($errorprefix,$result) > 0
  175. %break = %i > 2 | %yok | %yerror
  176.  
  177. until %break
  178.  
  179. if %i > 2 
  180.  
  181.   display DEBUG: We went thru three inputs? Phone's probbly ringing\n
  182.   display DEBUG: Dialing script aborted.
  183.   abort
  184. end
  185.  
  186. if %yerror
  187.    display Your modem returned ERROR in response to the init string, aborting.\n
  188.    abort
  189. end
  190. if %debuglevel > 1
  191. display DEBUG: Everything looks good, going to try to dial the phone.\n
  192. end
  193.  
  194. #
  195. #
  196. #
  197. #
  198. # send phone number
  199. #
  200. # Fix #3: Dialing the phone
  201. # -------------------------
  202. #
  203. #     The dial loop provided by the default login script is pretty weak, as
  204. #     it will not catch errors in the dialing string, badly handles BUSY
  205. #     signals, and does not take into account the possibillity of a RING
  206. #     response. 
  207. #
  208. #
  209. %dials = 0
  210. repeat
  211. #
  212. # Outer dialing loop begins here.
  213. #
  214. # First check to see that we haven't exceeded our max number of
  215. # dial attempts (0 = unlimited)
  216. #
  217.   if ! %attempts = 0
  218.   if %i = %attempts
  219.     display "Too many dial attempts"\n
  220.     abort
  221.   end
  222.   end
  223.   output $dialprefix$number\n
  224.  
  225. %i = 0
  226. %busy = 0
  227. %connected = 0
  228. %timeout = 0
  229. repeat
  230.  
  231. if [READ 60 $result]
  232. #
  233. # We did get a response of some sort, try to deal with it.
  234. # Some weird off brand modems that users will try to use (in the name
  235. # of saving a buck) will sometimes return odd strings like "voice call" or
  236. # "NO CARRIER" in response to busy signals or timed-out connect attempts.
  237. # Let's make sure we'll never choke if we see an unexected response...
  238. #
  239.  
  240.    %connected = pos($connect,$result)
  241.    if ! %connected
  242.    #
  243.    # We didn't get a connect response, see if we can match it.
  244.    #
  245.      if pos("BUSY",$result)
  246.      %busy = 1
  247.      end
  248.  
  249.      if pos("RING",$result)
  250.         display Incomming call detected, aborting...\n
  251.         abort
  252.      end
  253.  
  254.      if pos("ERROR",$result)
  255.         display Modem rejected dial command, aborting...\n
  256.         abort
  257.      end
  258.    #
  259.    # We did not match the string... Oh well. We will have to rely on
  260.    # the input timeout and the max loop count to save us from insanity. 
  261.    #
  262.    # Some users complained about getting the message the following message
  263.    # for their dial string, so we have this off by default (increase debuglevel
  264.    # to re-enable it).
  265.    if %debuglevel > 1
  266.         display DEBUG: We got back $result but do not understand it!\n
  267.    end
  268.    %i = %i + 1 
  269.    end
  270.  
  271. else
  272. display DEBUG: We timed out waiting for a response string from the modem.\n
  273. display DEBUG: Aborting...\n
  274. %timeout = 1
  275.  
  276. end
  277. until %connected | %busy | %timeout
  278.  
  279. # and another for the outer loop.
  280. until %connected
  281. #
  282. #
  283. # Fix #4: Actually logging in
  284. # ---------------------------
  285. #
  286. # We need to keep an eye out to make sure the user has supplied a valid
  287. # username and password combonation. Some users may give us "username.ppp",
  288. # others just "username", and still others will supply a bogus username /
  289. # password pair. This part of the script filters all these possibillities
  290. # out. In testing sonic's current equipment (2/17/96), it seems that users
  291. # can login as userneme.ppp.ppp and that will work. 
  292. #
  293. input 30 $userprompt
  294. output $username
  295. if ! pos(".ppp",$username)
  296. output .ppp
  297. end
  298. output \n
  299.  
  300. #
  301. # and the password
  302. #
  303. input 30 $passprompt
  304. output $password\n
  305. #
  306. # We now need to look for two things:
  307. # Invalid password
  308. # PPP session
  309. # Trumpet does not have a good way to do this, as it lacks multiple target
  310. # patttern matching and program flow control. We'll take the ugly way out and
  311. # assume that if we don't see the PPP startup message, that something else
  312. # is going on and then user can follow onscreen instructions. 
  313. #
  314. #
  315. if ! [input 15 "PPP ses"]
  316.    display \nDEBUG: We did not see the PPP startup message within 15 seconds.\n
  317.    display DEBUG: --------------------------------------------------------\n
  318.    display DEBUG: If there is a message above these lines that states "Invalid Login",\n
  319.    display DEBUG: then you have either entered your login information incorrectly in\n
  320.    display DEBUG: SETUP, or there is a problem with your account. Please re-enter your\n
  321.    display DEBUG: username and password, then try again.\n\n
  322.    display DEBUG: If there is NOT and "Invaid Login" message above, then most likely there\n
  323.    display DEBUG: is a temporary hardware problem at Sonic, and you should probbly try\n
  324.    display DEBUG: this again later.\n
  325.    display DEBUG: Script Aborting.\n
  326.    abort
  327. end
  328. #
  329. # we are now logged in. Check for 0.0.0.0 allocation....
  330. #
  331. if [input 2 "0.0.0.0"]
  332.    display DEBUG: Whoops! You've been assigned an invalid ip address of 0.0.0.0\n
  333.    display DEBUG: Try connecting again. If this problem persists, call\n
  334.    display DEBUG: Sonic technical support and report it.\n
  335.    display DEBUG: Script Aborted.
  336.    abort
  337. end
  338. if %debuglevel > 1
  339. Display \nDEBUG: We have a sucessful login!\N 
  340. end
  341.